define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'system.region/index',
        add_url: 'system.region/add',
        edit_url: 'system.region/edit',
        delete_url: 'system.region/delete',
        modify_url: 'system.region/modify',
        export_url: 'system.region/export',
        import_url: 'system.region/import',
    };

    var Controller = {

        index: function () {

            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus',
                        extend: '',
                    }],
                    'delete'
                    // ,'export',
                    // [{
                    //     text: '导入',
                    //     url: init.import_url,
                    //     method: 'open',
                    //     auth: 'import',
                    //     class: 'layui-btn layui-btn-success layui-btn-sm',
                    //     icon: 'fa fa-plus',
                    //     extend: '',
                    // }]
                ],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: '区域id'},
                    {field: 'name', minWidth: 80, title: '区划名称'},
                    {field: 'level', minWidth: 80, title: '区划等级'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            'delete',
                            [
                                {
                                    title: '确认补签？',
                                    text:'补签',
                                    url: init.self_region_url,
                                    method: 'request',
                                    class: 'layui-btn layui-btn-xs layui-btn-normal',
                                }
                            ]
                        ]
                    }
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        import: function() {
            ea.listen();
        }
    };
    return Controller;
});